@(ditte: List[Ditta], dittaForm: play.data.Form[Ditta],id: Long,daModificare: Ditta,warning: Boolean)

@import helper._

@main("Ditta") {
	
	<!-- COMBOBOX with AUTOCOMPLETE -->
	
	<link rel="stylesheet" href="@routes.Assets.at("autocomplete/jquery-ui-themes-1.10.3/themes/smoothness/jquery-ui.css")" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="@routes.Assets.at("autocomplete/jquery-ui.js")"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <style>
  .custom-combobox {
    position: relative;
    display: inline-block;
  }
  .custom-combobox-toggle {
    position: absolute;
    top: 0;
    bottom: 0;
    margin-left: -1px;
    padding: 0;
    /* support: IE7 */
    *height: 1.7em;
    *top: 0.1em;
  }
  .custom-combobox-input {
    margin: 0;
    padding: 0.3em;
    width: 10em;
  }
  </style>
  <script>
  (function( $ ) {
    $.widget( "custom.combobox", {
      _create: function() {
        this.wrapper = $( "<span>" )
          .addClass( "custom-combobox" )
          .insertAfter( this.element );
 
        this.element.hide();
        this._createAutocomplete();
        this._createShowAllButton();
      },
 
      _createAutocomplete: function() {
        var selected = this.element.children( ":selected" ),
          value = selected.val() ? selected.text() : "";
 
        this.input = $( "<input>" )
          .appendTo( this.wrapper )
          .val( value )
          .attr( "title", "" )
          .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
          .autocomplete({
            delay: 0,
            minLength: 0,
            source: $.proxy( this, "_source" )
          })
          .tooltip({
            tooltipClass: "ui-state-highlight"
          });
 
        this._on( this.input, {
          autocompleteselect: function( event, ui ) {
            ui.item.option.selected = true;
            this._trigger( "select", event, {
              item: ui.item.option
            });
          },
 
          autocompletechange: "_removeIfInvalid"
        });
      },
 
      _createShowAllButton: function() {
        var input = this.input,
          wasOpen = false;
 
        $( "<a>" )
          .attr( "tabIndex", -1 )
          .attr( "title", "Show All Items" )
          .tooltip()
          .appendTo( this.wrapper )
          .button({
            icons: {
              primary: "ui-icon-triangle-1-s"
            },
            text: false
          })
          .removeClass( "ui-corner-all" )
          .addClass( "custom-combobox-toggle ui-corner-right" )
          .mousedown(function() {
            wasOpen = input.autocomplete( "widget" ).is( ":visible" );
          })
          .click(function() {
            input.focus();
 
            // Close if already visible
            if ( wasOpen ) {
              return;
            }
 
            // Pass empty string as value to search for, displaying all results
            input.autocomplete( "search", "" );
          });
      },
 
      _source: function( request, response ) {
        var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
        response( this.element.children( "option" ).map(function() {
          var text = $( this ).text();
          if ( this.value && ( !request.term || matcher.test(text) ) )
            return {
              label: text,
              value: text,
              option: this
            };
        }) );
      },
 
      _removeIfInvalid: function( event, ui ) {
 
        // Selected an item, nothing to do
        if ( ui.item ) {
          return;
        }
 
        // Search for a match (case-insensitive)
        var value = this.input.val(),
          valueLowerCase = value.toLowerCase(),
          valid = false;
        this.element.children( "option" ).each(function() {
          if ( $( this ).text().toLowerCase() === valueLowerCase ) {
            this.selected = valid = true;
            return false;
          }
        });
 
        // Found a match, nothing to do
        if ( valid ) {
          return;
        }
 
        // Remove invalid value
        this.input
          .val( "" )
          .attr( "title", value + " didn't match any item" )
          .tooltip( "open" );
        this.element.val( "" );
        this._delay(function() {
          this.input.tooltip( "close" ).attr( "title", "" );
        }, 2500 );
        this.input.data( "ui-autocomplete" ).term = "";
      },
 
      _destroy: function() {
        this.wrapper.remove();
        this.element.show();
      }
    });
  })( jQuery );

	$(function() {
	    $( "#tipo_id" ).combobox();
  	});

	
  </script>
	
	
	
	
	<br>
	<p style="-webkit-text-stroke: #000000 1px; font-size: 39px; color:#3ADF00">Modifica Ditta</p>
    <br>
    
    @if(warning==true){
    	<div class="alert">
  			<button type="button" class="close" data-dismiss="alert">&times;</button>
  			<strong>Attenzione!</strong> Ditta già esistente!
		</div>
    }
            
    <div style="background: rgba(100,100,50,0.3);">
    <form action="@routes.Ditte.editDitta(id)" method="GET" class="form-horizontal" >
    
    	<dl class=" " id="tipo_id_field">
    		<label class="control-label"><br>Tipo*</label>
 			<div class="control-group info">
    			<div class="controls">
    				
                	@select(dittaForm("tipo.id"), options(Tipo.options),'_label -> "")
                </div>
        	</div>
        </dl>
    	
    	<dl class=" " id="nome_field">
    	<label class="control-label" for="inputNome">Nome*</label>
 		<div class="control-group info">
    		<div class="controls">
      			<input type="text" id="nome" name="nome" value="@daModificare.nome" placeholder="ad es. EIS" title="Max 100 caratteri">
    		</div>
  		</div>
  		</dl>
  		
        
        <dl class=" " id="indirizzo_field">
 		<div class="control-group">
    		<label class="control-label" for="inputIndirizzo">Indirizzo</label>
    		<div class="controls">
      			<input type="text" id="indirizzo" name="indirizzo" value="@daModificare.indirizzo"  placeholder="ad es. Via Pisino 155" title="Max 200 caratteri">
    		</div>
  		</div>
  		</dl>
  		
  		<dl class=" " id="citta_field">
 		<div class="control-group">
    		<label class="control-label" for="inputCitta">Città</label>
    		<div class="controls">
      			<input type="text" id="citta" name="citta" value="@daModificare.citta" placeholder="ad es. Roma" title="Max 100 caratteri">
    		</div>
  		</div>
  		</dl>
  		
  		<dl class=" " id="telefono_field">
  		<label class="control-label" for="inputTelefono">Telefono*</label>
 		<div class="control-group info">
    		<div class="controls">
      			<input type="text" id="telefono" name="telefono" value="@daModificare.telefono" placeholder="ad es. 06123456" title="Max 80 caratteri">
    		</div>
  		</div>
  		</dl>
  		
  		<dl class=" " id="fax_field">
 		<div class="control-group">
    		<label class="control-label" for="inputFax">Fax</label>
    		<div class="controls">
      			<input type="text" id="fax" name="fax"  value="@daModificare.fax" title="Max 80 caratteri">
    		</div>
  		</div>
  		</dl>
  		
  		<dl class=" " id="partitaIva_field">
  		<label class="control-label" for="inputPartitaIva">Partita IVA*</label>
 		<div class="control-group info">
    		<div class="controls">
      			<input type="text" id="partitaIva" name="partitaIva" value="@daModificare.partitaIva" title="Max 30 caratteri">
    		</div>
  		</div>
  		</dl>
         
        <dl class=" " id="codFiscale_field">
 		<div class="control-group">
    		<label class="control-label" for="inputCodFiscale">Codice Fiscale</label>
    		<div class="controls">
      			<input type="text" id="codFiscale" name="codFiscale" value="@daModificare.codFiscale" title="Max 40 caratteri">
    		</div>
  		</div>
  		</dl>
  		
  		<dl class=" " id="mail_field">
 		<div class="control-group">
    		<label class="control-label" for="inputMail">Mail</label>
    		<div class="controls">
    		<div class="input-prepend">
	    		<span class="add-on"><i class="icon-envelope"></i></span>
      			<input type="text" id="mail" name="mail"  placeholder="prova@@host.dom" value="@daModificare.mail"  style="width: 178px;" title="Max 100 caratteri">
    		</div>
    		</div>
  		</div>
  		</dl>
        
		<div class="controls">
       		<button type="submit" class="btn btn-primary">Modifica</button> &nbsp;&nbsp;*Campo obbligatorio
       	</div>
       	<br>
 	</form>
 	</div>
        
 
}